package com.itboye.mengwu.app.ui.mymeng;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.itboye.core.object.BaseFragment;
import com.itboye.mengwu.R;
import com.itboye.mengwu.widget.ToastUtil;

public class FragmentMyOrderTow extends BaseFragment {

	private Button btn;
	ListView listView;
	TextView total_price;

	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.fragment_myorder;
	}

	@Override
	public void onMyActivityCreated() {
		// TODO Auto-generated method stub
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View view) {
				// TODO Auto-generated method stub
				ToastUtil.myTosat(getActivity(), R.drawable.ic_dapei,
						"去商城看看吧...", 0);
			}
		});
		MyAdapter adapter = new MyAdapter(getActivity(),
				R.layout.item_wait_get_goods);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub

			}
		});
	}

	class MyAdapter extends BaseAdapter {
		Context context;
		int resID;

		public MyAdapter(Context context, int resID) {
			this.context = context;
			this.resID = resID;
		}

		@Override
		public int getCount() {
			return 10;
		}

		@Override
		public Object getItem(int position) {
			return position;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = CreateView();

			}
			return convertView;
		}

		// @SuppressLint("InflateParams")
		private View CreateView() {
			View v = null;
			LayoutInflater inflater = LayoutInflater.from(getActivity());
			v = inflater.inflate(R.layout.item_shouhou, null);
			total_price = (TextView) v.findViewById(R.id.total_price);
			total_price.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent intent = new Intent(context,
							ActivityShenQingShouHou.class);
					startActivity(intent);
				}
			});
			return v;
		}

	}

}
